package cn.SiFuLan.controls;

import cn.SiFuLan.dao.IskuDao;
import cn.SiFuLan.dao.impl.skuDaoImapl;
import cn.SiFuLan.entity.skuEntity;
import cn.SiFuLan.entity.spuEntity;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.List;

@WebServlet(urlPatterns = "/admin/skuindex.do")
public class skuServlt extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        IskuDao iskuDao=new skuDaoImapl();
        skuEntity skuEntity=new skuEntity();

        String name=request.getParameter("uname");
        skuEntity.setTitle(name);

        String color=request.getParameter("color");
        skuEntity.setColor(color);

        String spuid= request.getParameter("supid");
        if(spuid!=null && !spuid.equals("")){
            skuEntity.setSpu_id(Integer.parseInt(spuid));
        }
        List<skuEntity> sku=iskuDao.aall(skuEntity);
        request.setAttribute("sku",sku);
        request.setAttribute("spuid",spuid);
        request.getRequestDispatcher("skuindex.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    }
}
